added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / CSAzureWCFServices / WorkerRole1 / WCFService.cs
blob776a2ae3e57cb4c8ac170b9674455dc4c0065f3a
1 /****************************** Module Header ******************************\
2 * Module Name: WCFService.cs
3 * Project: CSAzureWCFServices
4 * Copyright (c) Microsoft Corporation.
5 *
6 * This class implements WCFService.IContract interface.
7 * Methods directly returns information about the current work role.
8 *
9 * This source is subject to the Microsoft Public License.
10 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 * All other rights reserved.
13 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 \***************************************************************************/
18 using System;
19 using WCFContract;
20 using Microsoft.WindowsAzure;
21 using Microsoft.WindowsAzure.Diagnostics;
22 using Microsoft.WindowsAzure.ServiceRuntime;
23 using System.ServiceModel;
25 namespace WorkerRole1
27 // Implement the wcf contract WCFContract.IContract
28 class WCFService:WCFContract.IContract
30 // Return the current work role's name and instance id
31 public string GetRoleInfo()
33 RoleInstance currentRoleInstance = RoleEnvironment.CurrentRoleInstance;
34 string RoleName = currentRoleInstance.Role.Name;
35 string RoleInstanceID = currentRoleInstance.Id;
36 return (string.Format("You are talking to role {0}, instance ID {1}\n.", RoleName, RoleInstanceID));
39 // Return the channel between the client & the work role
40 public string GetCommunicationChannel()
42 return (string.Format("You are talking via {0}.", OperationContext.Current.Channel.LocalAddress.Uri.ToString()));